package com.gof.example.algorithm;

/**
 * Created with IntelliJ IDEA.
 * Created by zhiyuan on 2018/5/13 15:15.
 * haiming.fei@tongdun.cn
 */
public enum Fly {
    SubSonicFly("亚音速飞行", 1),SuperSonicFly("超音速飞行", 2);
    private String name;
    private int value;

    Fly(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public static Fly getByValue(int v) {
        Fly[] values = values();
        for (int i = 0; i < values.length; i++) {
            Fly fly = values[i];
            if (fly.getValue() == v) {
                return fly;
            }
        }

        return null;
    }
}
